package com.ruoyi.web.controller.aaa;

import com.ruoyi.web.entity.User;
import com.ruoyi.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    public String list(ModelMap modelMap){
        List<User> all = userService.all();
        modelMap.put("users",all);
        return "/my/list";
    }

    @RequestMapping("/add")
    public String add(){
        return "/my/add";
    }

    @RequestMapping("/add1")
    public String add1(User user,ModelMap modelMap){
        userService.add(user);
        List<User> all = userService.all();
        modelMap.put("users",all);
        return "/my/list";
    }
    @RequestMapping("/row")
    public String row(){
        return "/my/row";
    }
    @RequestMapping("/row1")
    public String row1(int id,ModelMap modelMap){
        userService.row(id);
        List<User> all = userService.all();
        modelMap.put("users",all);
        return "redirect:list";
    }
    @RequestMapping("/del")
    public String del(){
        return "/my/del";
    }
    @RequestMapping("/del1")
    public String del1(User user,ModelMap modelMap){
        userService.del(user);
        return "redirect:list";
    }


}
